package com.mystudy.management.usermanagement.controller;


import cn.dev33.satoken.exception.NotLoginException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;


//异常处理控制器
@ControllerAdvice
public class ErrorController {


    //未登录跳转视图
    @ExceptionHandler(NotLoginException.class)
    public String toLoginPage(Model model){
        model.addAttribute("status","尚未登录或者会话已过时");
        return "redirect:/";
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public String handle(Exception e, Model model) {
        return "出现了一些错误，错误信息：" +
                ""+e.getMessage();
    }


}
